<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>祈贝健康--后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />

    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/animate.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style-responsive.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/theme/default.css" rel="stylesheet" id="theme" />
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== BEGIN PAGE LEVEL STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
    <!-- ================== END PAGE LEVEL STYLE ================== -->

    <!-- ================== BEGIN BASE JS ================== -->
    <script src="./Public/Admin/assets/plugins/pace/pace.min.js"></script>
    <!-- ================== END BASE JS ================== -->
</head>
<body>
<php> include './Public/Admin/header.html'; </php>
    
    
    
<!-- begin #content -->
		<div id="content" class="content">
			<!-- begin breadcrumb -->
			<ol class="breadcrumb pull-right">
				<li><a href="javascript:;">首页</a></li>
				<li><a href="javascript:;">角色管理</a></li>
				<li class="active">设置权限</li>
                                
			</ol>
			<!-- end breadcrumb -->
			<!-- begin page-header -->
			<h1 class="page-header">角色管理 <small>设置权限</small></h1>
			<!-- end page-header -->
			
			<!-- begin row -->
			<div class="row">
			    <!-- begin col-12 -->
			    <div class="col-md-12">
			        <!-- begin panel -->
                    <div class="panel panel-inverse">
                        <div class="panel-heading">
                            <div class="panel-heading-btn">
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                            </div>
                            <h4 class="panel-title">添加医院</h4>
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive"> 
                                
                                
                                                                  <!--表单--> 
                                    
                            <div class='col-md-10' id="role">
<!--                                <div class="form-group">
                                    <label class="col-md-2 control-label"><span><i class="fa fa-lg fa-home"></i> <input id="top_2" name="module_id[]" value="2" checked="" onclick="mySelected(this.checked,'top_2')" type="checkbox"> 系统管理:</span></label>

                                    <div class="col-md-10">
                                        <span style="float: left; padding-left:25px "> <label class="checkbox inline-block">
                                            <input name="module_id[]" class="top_2" value="18" onclick="myCheck(2)" type="checkbox">
                                                <i></i>角色管理</label> 
                                        </span>
                                        <span style="float: left; padding-left:25px "> <label class="checkbox inline-block">
                                            <input name="module_id[]" class="top_2" value="4" onclick="myCheck(2)" type="checkbox">
                                            <i></i>用户管理</label> 
                                        </span>
                                                                                
                                    </div>
                                </div>-->


                    
                                        </div>
                                    
                                
                            </div>
                        </div>
                    </div>
                    <!-- end panel -->
                </div>
                <!-- end col-12 -->
            </div>
            <!-- end row -->
		</div>
		<!-- end #content -->


<!-- begin scroll to top btn -->
<a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
<!-- end scroll to top btn -->
<?php include './header.html'; ?>
<!-- end page container -->

<!-- ================== BEGIN BASE JS ================== -->
<script src="./Public/Admin/assets/plugins/jquery/jquery-1.9.1.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery/jquery-migrate-1.1.0.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js"></script>
<script src="./Public/Admin/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="./Public/Admin/assets/crossbrowserjs/html5shiv.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/respond.min.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/excanvas.min.js"></script>
<![endif]-->
<script src="./Public/Admin/assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- ================== END BASE JS ================== -->

<!-- ================== BEGIN PAGE LEVEL JS ================== -->
<script src="./Public/Admin/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
<script src="./Public/Admin/assets/plugins/DataTables/js/dataTables.colVis.js"></script>
<script src="./Public/Admin/assets/js/apps.min.js"></script>
<!-- ================== END PAGE LEVEL JS ================== -->
<script>
		$(document).ready(function() {
			App.init();
                        loadmanager();
		});
                //加载权限
                function loadmanager(){
                    $.getJSON("index.php?m=Admin&c=Role&a=manager_list",function(result){
                        var html='';
                        if(result!=null){
                            $.each(result, function(key, val) {
                                html+='<div class="form-group">';
                                html+='<label class="col-md-2 control-label"><span><i class="fa fa-lg"></i> <input id="top_'+val.id+'" name="module_id[]" value="'+val.id+'" checked="" onclick="mySelected(this.checked,\'top_'+val.id+'\')" type="checkbox"> '+val.name+':</span></label>';
                                html+='<div class="col-md-10">';
                                if(val.index!=null){
                                    $.each(val.index, function(k, v) {
                                        if(v.isc==1){
                                            html+='<span style="float: left; padding-left:25px "> <label class="checkbox inline-block">';
                                            html+='<input name="module_id[]" class="top_'+val.id+'" value="'+v.id+'" checked="" onclick="myCheck('+val.id+')" type="checkbox">';
                                            html+='<i></i>'+v.name+'</label> ';
                                            html+='</span>';
                                        }else{
                                            html+='<span style="float: left; padding-left:25px "> <label class="checkbox inline-block">';
                                            html+='<input name="module_id[]" class="top_'+val.id+'" value="'+v.id+'" onclick="myCheck('+val.id+')" type="checkbox">';
                                            html+='<i></i>'+v.name+'</label> ';
                                            html+='</span>';
                                        }
                                    });
                                }
                                html+='</div>';
                                html+='</div>';
                                
                                
                            });
                            html+='<div class="form-group">';
                            html+='<div class="col-md-2">';
                            html+='<a class="btn btn-primary" onclick=sub()>';
                            html+='<i class="fa"></i>确定</a></div></div>';
                            $("#role").html(html);
                        }
                    });
                }
                
                
                function myCheck(top_id){
                    var objs = document.getElementsByClassName("top_"+top_id);
                    var c=false;
                    for(var i=0;i<objs.length;i++){
                        if(objs[i].checked){
                            c=true;
                            break;
                        }
                    }
                    document.getElementById('top_'+top_id).checked=c;
                }

                function mySelected(c,top_id){

                    var objs = document.getElementsByClassName(top_id);
                    for(var i=0;i<objs.length;i++){
                        objs[i].checked=c;
                    }

                }
                function sub(){
                    var aa='';
                    $("input[type=checkbox]").each(function(){
                        if(this.checked){
                            aa+=$(this).val()+',';
                        }
                    });
                    $.getJSON("index.php?m=Admin&c=Role&a=update_manager&model_id="+aa,function(result){
                        if(result==0){
                            alert("修改失败");
                        }else{
                            window.location="index.php?m=Admin&c=Role&a=lists";
                        }
                    });
                }
	</script>


</body>
</html>

